package com.koron.order.common.controller;

import com.github.pagehelper.PageInfo;
import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.order.common.bean.po.OrderReassignPo;
import com.koron.order.common.service.OrderReassignService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * (OrderReassign)表控制层
 *
 * @author zhouj
 * @since 2022-03-22 11:49:41
 */
@Api(tags = "(OrderReassign)")
@RestController
@RequestMapping("/orderReassign/")
public class OrderReassignController {

    @Autowired
    private OrderReassignService orderReassignService;

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @ApiOperation(value = "新增或修改")
    @PostMapping("insertOrUpdate")
    public Response<Integer> insertOrUpdate(@RequestBody OrderReassignPo orderReassign) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderReassignService, "insertOrUpdate", Integer.class, orderReassign));
    }

    @ApiOperation(value = "新增")
    @PostMapping("insert")
    public Response<Integer> insert(@RequestBody OrderReassignPo orderReassign) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderReassignService, "insert", Integer.class, orderReassign));
    }

    @ApiOperation(value = "批量新增")
    @PostMapping("insertBatch")
    public Response<Integer> insertBatch(@RequestBody List<OrderReassignPo> orderReassignList) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderReassignService, "insertBatch", Integer.class, orderReassignList));
    }

    @ApiOperation(value = "根据id更新")
    @PutMapping("update")
    public Response<Integer> update(@RequestBody OrderReassignPo orderReassign) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderReassignService, "update", Integer.class, orderReassign));
    }

    @ApiOperation(value = "根据id删除")
    @DeleteMapping("deleteById")
    public Response<Integer> deleteById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderReassignService, "deleteById", Integer.class, id));
    }

    @ApiOperation(value = "根据id查询")
    @GetMapping("queryById")
    public Response<OrderReassignPo> queryById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderReassignService, "queryById", OrderReassignPo.class, id));
    }

    @ApiOperation(value = "根据工单id查询最新的一条数据")
    @GetMapping("queryLatestByOrderId")
    public Response<OrderReassignPo> queryLatestByOrderId(String orderId) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderReassignService, "queryLatestByOrderId", OrderReassignPo.class, orderId));
    }

    @ApiOperation(value = "不分页查询列表")
    @GetMapping("queryList")
    public Response<List> queryList(OrderReassignPo queryVo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderReassignService, "queryList", List.class, queryVo));
    }

    @ApiOperation(value = "分页查询列表")
    @GetMapping("queryPageList")
    public Response<PageInfo> queryPageList(OrderReassignPo queryPo, PageQuery pageQuery) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderReassignService, "queryPageList", PageInfo.class, queryPo, pageQuery));
    }

    @ApiOperation(value = "通知派工责任人派工")
    @GetMapping("notifyDispatch")
    public Response<Integer> notifyDispatch(String currDs) {
        return Response.ok(ADOConnection.runTask(currDs, orderReassignService, "notifyDispatch", Integer.class,currDs));
    }

}
